#pragma once

#include "protocol/transport.pb.h"
#include "Serializer.h"
#include <string>
#include <msgpack.hpp>
#include <type_traits> // 引入std::enable_if和std::conditional

namespace zeroplus::mq
{
    // ---------------------- 协议编解码器 ----------------------
    template <typename T>
    struct ProtocolCodec
    {
        static T Decode(const Bytes &bytes)
        {
            T obj;
            Serializer::convert(bytes, obj);
            return obj;
        }

        static Bytes Encode(const T &obj)
        {
            Bytes bytes;
            Serializer::convert(obj, bytes);
            return bytes;
        }
    };
}
